<!DOCTYPE html>
<#include "/ftl/header.ftl">
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
</head>
<script type="text/javascript">

    $(document).ready(function(){
        $("#btnsub").on("click",function(){
            $("#formData").submit();
        });
    });

    function add () {
        window.location.href = "../role/add";

    }
    function edit(a) {
        window.location.href = "../role/edit?id=" + a;
    }

    function del(a,b){
        window.location.href = "../role/del?id=" + a+"&status="+b;
    }

</script>
<#include "/ftl/menu.ftl">
<body>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li><a href="#">用户管理</a></li>
                <li><a href="#">角色管理</a></li>
                <li class="active">角色列表</li>
            </ol>
        </div>
    </div>
    <div class="col-md-12">
    <form  method="post"  enctype="multipart/form-data" id="formData">
        <div class="row">
            <div class="col-md-12">
                <div class="block">
                    <div class="form-row">
                        <div class="col-md-11">
                        </div>
                        <div class="col-md-1">
                            <@shiro.hasPermission name="role:add">
                            <div><button class="btn btn-default btn-clean"
                                         type="button" onclick="add()">添加</button></div>
                        </@shiro.hasPermission>
                        </div>
                        
                        <div class="content">
                        <table class="table table-bordered table-striped table-hover">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>角色名称</th>
                                <th>角色状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#if roleList??>
                            <#list roleList as role>
                            <tr>
                                <input type="hidden" name="roleId" value="${role.id}" />
                                <td>${role_index+1}</td>
                                <td>${role.roleName}</td>
                                <td>  <#if role.status == 1>
                                    正常
                                </#if>
                                <#if role.status == 0>
                                禁用
                                 </#if>
                                </td>
                            <td>
                                <#if role.roleName=='admin'>
                                管理员角色不可修改
                                </#if>
                                <#if role.roleName!='admin'>
                                <@shiro.hasPermission name="role:edit">
                            <button class="btn btn-default btn-clean"
                                type="button" onclick="edit(${role.id})">编辑/权限</button></td>
                            </@shiro.hasPermission>
                            </#if>

                            </tr>
                            </#list>
                        </#if>
                        </tbody>
                        </table>
                    </div>
                </div>
            </div>
    </form>
</div>
</div>
</body>
</html>